Filter out shadow mounts
authorMatthias Clasen <matthiasc@src.gnome.org>
Mon, 1 Dec 2008 05:42:28 +0000 (05:42 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 1 Dec 2008 05:42:28 +0000 (05:42 +0000)
svn path=/trunk/; revision=21838

ChangeLog
gtk/gtkfilesystem.c

index da3dc648971b1ed61f83852eeb93b8a9916c67b1..ac2f7076c0e402364f6ddaf37a641c4f96225124 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,11 @@
-2008-12-01  Matthisa Clasen <mclasen@redhat.com>
+2008-12-01  Matthias Clasen <mclasen@redhat.com>
+
+       Bug 555334 – connected server feature
+
+       * gtk/gtkfilesystem.c (get_volumes_list): Filter out shadow mounts.
+       Patch by David Zeuthen.
+
+2008-12-01  Matthias Clasen <mclasen@redhat.com>
 
        * gtk/gtkentry.c: Revert an accidental change that sneaked
        in with the last commit.
index 3960be29bb242b6e45bb1a674dda0b4dc4e53c5e..a46f60c620c7836ff274d2eb1fec8c5a55ef5a10 100644 (file)
@@ -362,6 +362,39 @@ bookmarks_file_changed (GFileMonitor      *monitor,
     }
 }
 
+static gboolean
+mount_referenced_by_volume_activation_root (GList *volumes, GMount *mount)
+{
+  GList *l;
+  GFile *mount_root;
+  gboolean ret;
+
+  ret = FALSE;
+
+  mount_root = g_mount_get_root (mount);
+
+  for (l = volumes; l != NULL; l = l->next)
+    {
+      GVolume *volume = G_VOLUME (l->data);
+      GFile *volume_activation_root;
+
+      volume_activation_root = g_volume_get_activation_root (volume);
+      if (volume_activation_root != NULL)
+        {
+          if (g_file_has_prefix (volume_activation_root, mount_root))
+            {
+              ret = TRUE;
+              g_object_unref (volume_activation_root);
+              break;
+            }
+          g_object_unref (volume_activation_root);
+        }
+    }
+
+  g_object_unref (mount_root);
+  return ret;
+}
+
 static void
 get_volumes_list (GtkFileSystem *file_system)
 {
@@ -468,8 +501,6 @@ get_volumes_list (GtkFileSystem *file_system)
         }
     }
 
-  g_list_free (volumes);
-
   /* add mounts that has no volume (/etc/mtab mounts, ftp, sftp,...) */
   mounts = g_volume_monitor_get_mounts (priv->volume_monitor);
 
@@ -484,10 +515,20 @@ get_volumes_list (GtkFileSystem *file_system)
           continue;
         }
 
+      /* if there's exists one or more volumes with an activation root inside the mount,
+       * don't display the mount
+       */
+      if (mount_referenced_by_volume_activation_root (volumes, mount))
+        {
+          continue;
+        }
+
       /* show this mount */
       priv->volumes = g_slist_prepend (priv->volumes, g_object_ref (mount));
     }
 
+  g_list_free (volumes);
+
   g_list_free (mounts);
 }